package com.ztorn.fiscale.service.impl;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ztorn.fiscale.mapper.FiscaleTaxInvoiceMapper;
import com.ztorn.fiscale.domain.FiscaleTaxInvoice;
import com.ztorn.fiscale.service.IFiscaleTaxInvoiceService;

/**
 * 税务发票Service业务层处理
 * 
 * @author ztorn
 * @date 2025-09-19
 */
@Service
public class FiscaleTaxInvoiceServiceImpl implements IFiscaleTaxInvoiceService 
{
    @Autowired
    private FiscaleTaxInvoiceMapper fiscaleTaxInvoiceMapper;

    /**
     * 查询税务发票
     * 
     * @param invoiceId 税务发票ID
     * @return 税务发票
     */
    @Override
    public FiscaleTaxInvoice selectFiscaleTaxInvoiceById(Long invoiceId)
    {
        return fiscaleTaxInvoiceMapper.selectFiscaleTaxInvoiceById(invoiceId);
    }

    /**
     * 查询税务发票列表
     * 
     * @param fiscaleTaxInvoice 税务发票
     * @return 税务发票
     */
    @Override
    public List<FiscaleTaxInvoice> selectFiscaleTaxInvoiceList(FiscaleTaxInvoice fiscaleTaxInvoice)
    {
        return fiscaleTaxInvoiceMapper.selectFiscaleTaxInvoiceList(fiscaleTaxInvoice);
    }

    /**
     * 新增税务发票
     * 
     * @param fiscaleTaxInvoice 税务发票
     * @return 结果
     */
    @Override
    public int insertFiscaleTaxInvoice(FiscaleTaxInvoice fiscaleTaxInvoice)
    {
        return fiscaleTaxInvoiceMapper.insertFiscaleTaxInvoice(fiscaleTaxInvoice);
    }

    /**
     * 修改税务发票
     * 
     * @param fiscaleTaxInvoice 税务发票
     * @return 结果
     */
    @Override
    public int updateFiscaleTaxInvoice(FiscaleTaxInvoice fiscaleTaxInvoice)
    {
        return fiscaleTaxInvoiceMapper.updateFiscaleTaxInvoice(fiscaleTaxInvoice);
    }

    /**
     * 批量删除税务发票
     * 
     * @param invoiceIds 需要删除的税务发票ID
     * @return 结果
     */
    @Override
    public int deleteFiscaleTaxInvoiceByIds(Long[] invoiceIds)
    {
        return fiscaleTaxInvoiceMapper.deleteFiscaleTaxInvoiceByIds(invoiceIds);
    }

    /**
     * 删除税务发票信息
     * 
     * @param invoiceId 税务发票ID
     * @return 结果
     */
    @Override
    public int deleteFiscaleTaxInvoiceById(Long invoiceId)
    {
        return fiscaleTaxInvoiceMapper.deleteFiscaleTaxInvoiceById(invoiceId);
    }
    
    /**
     * 撤销税务发票
     * 
     * @param invoiceId 税务发票ID
     * @return 结果
     */
    @Override
    public int revokeFiscaleTaxInvoice(Long invoiceId)
    {
        FiscaleTaxInvoice invoice = new FiscaleTaxInvoice();
        invoice.setInvoiceId(invoiceId);
        invoice.setStatus("已撤销");
        return fiscaleTaxInvoiceMapper.updateFiscaleTaxInvoice(invoice);
    }
    
    /**
     * 重新开具税务发票
     * 
     * @param invoiceId 税务发票ID
     * @return 结果
     */
    @Override
    public int reissueFiscaleTaxInvoice(Long invoiceId)
    {
        FiscaleTaxInvoice invoice = new FiscaleTaxInvoice();
        invoice.setInvoiceId(invoiceId);
        invoice.setStatus("已开具");
        return fiscaleTaxInvoiceMapper.updateFiscaleTaxInvoice(invoice);
    }
}